<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------
/**
 * Class Order
 * Desc  用户订单校验
 * Create on 2024/10/25 11:21
 * Create by wangyafang
 */

namespace app\api\validate\wddj\user;


use think\Validate;

class Order extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'type'=>'require|checkType',
        'city'=>'require',
        'from_address'=>'require',
        'from_lat'=>'require',
        'from_lng'=>'require',
        'to_address'=>'require',
        'to_lat'=>'require',
        'to_lng'=>'require',
        'driver_number'=>'require',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'type.require'=>'请选择订单类型',
        'city.require'=>'城市名称不能为空',
        'from_address.require'=>'请选择出发地',
        'from_lat.require'=>'出发地纬度不能空',
        'from_lng.require'=>'出发地经度不能空',
        'to_address.require'=>'请选择目的地',
        'to_lat.require'=>'目的地纬度不能空',
        'to_lng.require'=>'目的地经度不能空',
        'driver_number.require'=>'请选择司机数量',
    ];

    protected function checkType($value,$rule,$data)
    {
        if ($value == 2 && empty($data['departure_time'])) {
            return '请选择出发时间';
        }
        return true;
    }
}



 